// import { createStore, applyMiddleware, combineReducers } from 'redux'
import { createStore, applyMiddleware } from '../kredux'
import thunk from 'redux-thunk' // redux异步中间件
import logger from 'redux-logger' // 打印 logger 日志

export const counterReducer = (state = 0, {type, payload = 1}) => { // counterReducer 初始化、修改状态函数 定义修改规则
  switch (type) {
    case 'ADD':
      return state + payload
    case 'MINUS':
      return state - payload
    default:
      return state
  }
}


const store = createStore(counterReducer, applyMiddleware(thunk, logger)) //  createStore创建store

export default store